package com.ruoyi.web.controller.common;

import com.ruoyi.com.domain.vo.*;
import com.ruoyi.com.service.IComService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统通用请求
 *
 * @author sunye
 */
@RestController
@RequestMapping("/comController")
@Api(tags = "公共业务功能管理")
public class ComController extends BaseController
{

    @Autowired
    private IComService commService;

    /**
     * 查询终端名称列表
     */
    @PostMapping("/terminalMainList")
    @ApiOperation(value = "获取终端信息（公众号、小程序等）", notes = "获取终端信息（公众号、小程序等）")
    public AjaxResult terminalMainList(@RequestBody TerminalMainInfoListQuery terminalMainInfoListQuery)
    {
        terminalMainInfoListQuery.setDeptId(getDeptId());
        List<CustomTerminalMainInfoPO> list = commService.terminalMainList(terminalMainInfoListQuery);
        return success(list);
    }

    /**
     * 查询终端名称
     */
    @PostMapping("/getTerminalName")
    @ApiOperation(value = "获取终端名称", notes = "获取终端名称")
    public AjaxResult getTerminalName(@RequestBody TerminalMainNameQuery terminalMainNameQuery)
    {
        String terminalName = commService.getTerminalName(terminalMainNameQuery.getTerminalId(),terminalMainNameQuery.getTerminalType());
        return success(terminalName);
    }


    @PostMapping(value = "/getAreaList")
    @ApiOperation(value = "获取区域")
    public AjaxResult getAreaList(@RequestBody GetAreaQuery query) {
        return AjaxResult.success(commService.getAreaList(query));
    }



    /**
     * 查询当前系统前端功能列表
     */
    @GetMapping("/getFrontFunctionList")
    @ApiOperation(value = "查询当前系统前端功能列表", notes = "查询当前系统前端功能列表")
    public AjaxResult getFrontFunctionList(FrontFunctionQuery query)
    {
        query.setDeptId(getDeptId());
        List<OperateSystemFunctionVo> list = commService.getFrontFunctionList(query);
        return success(list);
    }

}
